package com.sskj.mine.asset;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.util.PopUtil;
import com.sskj.mine.asset.data.RechargeBean;
import com.sskj.mine.asset.data.RechargeTypeBean;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.presenter.BasePresenter;
import com.sskj.mine.asset.RechargeActivity;

import java.util.List;


/**
 * @author Hey
 * Create at  2019/05/03
 */
class RechargePresenter extends BasePresenter<RechargeActivity> {


    /**
     * 币充值页面
     *
     * @param coin_type 币种类型（可充值列表接口返回的类型）
     * @return
     */
    public void recharge(String coin_type) {
        httpService.recharge(coin_type).execute(new JsonCallBack<HttpData<RechargeBean>>() {
            @Override
            public void onSuccess(Response<HttpData<RechargeBean>> response) {
                HttpData<RechargeBean> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {

                    mView.updateUI(httpData.getData());
                }
            }
        });
    }


    public void getType() {
        httpService.rechargeList()
                .execute(new JsonCallBack<HttpData<List<RechargeTypeBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<RechargeTypeBean>>> response) {
                        HttpData<List<RechargeTypeBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {

                            mView.updateType(httpData.getData());
                        }
                    }
                });

    }
}
